package island.gotenyama.wand.bean;

/**
 * SQLを生成するクラス
 * 
 * @author tk
 */
public class SQLGen {

	private static final String E = "=";
	private static final String Q = "'";
	private static final String W = " ";
	
	private StringBuilder sb;
	
	public SQLGen() {
		sb = new StringBuilder();
	}
	
	public SQLGen(String sql) {
		sb = new StringBuilder(sql);
	}
	
	public SQLGen add(String append) {
		sb.append(append + W);
		return this;
	}
	
	public SQLGen eqo(String key, String append) {
		sb.append(key + E + append + W);
		return this;
	}
	
	public SQLGen quo(String key, String append) {
		sb.append(key + E + Q + append + Q + W);
		return this;
	}
	
	public SQLGen and() {
		final String AND = "and" + W;
		sb.append(AND);
		return this;
	}
	
	public SQLGen or() {
		final String AND = "or" + W;
		sb.append(AND);
		return this;
	}
	
	public String generate() {
		return sb.toString();
	}
}
